
function initOrder(){
	findDetailAjax.send();
}
//查询最新物流信息成功
function onLogisSucc(re){
	if(re.success || re.success == 'true'){
		var data = re.info;
		//有物流信息，可新增和修改物流信息
		if(data != null){
			$('#updateLogisBtn').show();
			$('#detailLogisBtn').show();
			$('#logisticsId').val(data.logisId);
			//收货信息
			$('#logisticsName').text(data.receiverName);
			$('#logisticsPhone').text(data.receiverPhone);
			$('#logisticsAddr').text(data.receiverAddr);
			$('#logisticsRemark').text(data.receiverRemark || '');
			$('#receiverState').text(data.receiverState=='01'?"已收货":"未收货");
			//物流公司、单号
			$('#logisticsType').text(data.logisCompany || '');
			$('#logisticsNum').text(data.logisNo || '');
			//发货信息
			$('#consignorName').text(data.consignorName);
			$('#consignorPhone').text(data.consignorPhone);
			$('#consignorTime').text(data.consignorTime);
			$('#consignorAddr').text(data.consignorAddr || '');
			$('#consignorRemark').text(data.consignorRemark || '');
			//系统备注
			$('#sysRemark').html(data.sysRemark || '');
		}else{
			$('#updateLogisBtn').hide();
			$('#detailLogisBtn').hide();
		}
	}
}
//查询订单详情成功
function onSuccess(re){
	findNewestLogisAjax.send();
	if(re.success || re.success == 'true'){
		$("#orderDetailFrm").autofill(re.info);
		var data = re.info;
		//租赁中、换货中、维修中  可修改物流信息，其余状态不可以修改
		$('#orderId').text(data.orderId);
		$('#createdTime').text(data.createdTime);
		$('#orderState').text(data.orderState);
		$('#orderStateTxt').text(
				$('#StatesSel').find('option[value="'+data.orderState+'"]').text());
		
		$('#auditStaff').text(data.auditStaffName || data.auditStaff || '');
		if(data.auditResult != null && data.auditResult.length > 0){
			$('#auditResult').text(data.auditResult=='01'?'通过':'不通过');
//			if(data.auditResult=='02'){
				$('#auditRemark').text(data.auditRemark);
//			}
		}
		
		if(data.imgUrl != null && data.imgUrl.length > 0){
			$('#procutImg').attr('src',data.imgUrl);
		}
		$('#productName').text(data.productName || '');
		if(data.allCondition != null && data.allCondition.length > 0 ){
			var conds = data.allCondition.split(",");
			var html = '';
			$.each(conds,function(index,item){
				html += '<span style="margin-right:0.8em">'+item.split(":")[1]+
					"</span>";
			});
			$('#productInternet').html(html); 
		}
		
		$('#logisticsName').text(data.logisticsName);
		$('#logisticsPhone').text(data.logisticsPhone);
		$('#logisticsType').text(data.logisticsType || '');
		$('#logisticsNum').text(data.logisticsNum || '');
		$('#logisticsAddr').text(data.logisticsAddr);
		$('#logisticsRemark').text(data.logisticsRemark || '');
		$('#stagesNum').text(data.stagesNum);
		
//		$('#stageBegin').text(data.stageBegin || '');
		$('#stageBegin').text(data.createdTime.substr(0,10) || '');
		
		$('#stageOneAmt').text(data.stageOneAmt);
		$('#rentAmt').text(data.rentAmt || '');
		$('#repayDate').text(data.repayDate || '');
		$('#bankType').text(data.bankType || '');
		$('#banckAccountNo').text(data.banckAccountNo);
		$('#bankCustName').text(data.bankCustName);
		$('#insuranceAmt').text(data.insuranceAmt);
		
		$('#custNo').text(data.custNo);
		$('#custName').text(data.custName);
		$('#custPhone').text(data.custPhone);
		$('#custIdCard').text(data.custIdCard);
		
		$('#stagesNumPro').text(data.stagesNum);
		$('#totalAmt').text(data.totalAmt);
		$('#buyOutAmt').text(data.buyOutAmt);
		
		//押金
		$('#depositAmt').html(data.depositAmt);
		$('#depositState').html(orderCodes.depositState[data.depositState]);
		
		//查找产品详情
		findProductAjax.addParam("orderId",data.orderId);
		findProductAjax.send();
	}
}

function showProduct(re){
	if(re.success || re.success == 'true'){
		$('#productType').text(re.info.productType);
	}
}

/**
 * 新增物流信息
 */
function createLogistics(){
	var url = ctx+"/yzj/orderLogistics/edit/"+$("#orderId").text()+"/01";
	MsgBox.open("createLogis", "新增物流", url, "900px");
}
function updateLogistics(){
	var url = ctx+"/yzj/orderLogistics/edit/"+$("#orderId").text()+"/02";
	MsgBox.open("updateLogis", "修改物流", url, "900px");
}
function hisLogistics(){
	var url = ctx+"/yzj/orderLogistics/listHtml/"+$("#orderId").text();
	MsgBox.open("hisLogis", "物流列表", url, "1200px");
}
function detailLogistics(){
	var id = $('#logisticsId').val();
	var url = ctx + "/yzj/orderLogistics/logisDetail/"+id;
	MsgBox.open("logisticsDetail", "物流详情", url, "900px");
}
function showInstallDetail(){
	var url = ctx + "/yzj/orderManage/repayRecord/"+$('#orderId').text();
	MsgBox.open("repayRecord", "还款记录", url, "1300px");
}

var openPage = {
		//订单状态修改页面
		editOrderState:function(){
			var url = ctx + "/yzj/orderManage/editState/"+$('#orderId').text();
			MsgBox.open("editState", "订单状态修改", url, "500px");
		},
		//订单状态修改记录
		orderStateEditLog:function(){
			var url = ctx + "/yzj/orderManage/editStateLog/"+$('#orderId').text();
			MsgBox.open("editStateLog", "订单状态修改记录", url, "1300px");
		},
		//押金状态修改
		editDepositState:function(){
			var url = ctx + "/yzj/orderManage/depositEdit/"+$('#orderId').text();
			MsgBox.open("editDepositState", "押金状态修改", url, "500px");
		}
}
/**
 * 刷新物流信息
 */
function refreshLogis(){
	findNewestLogisAjax.send();
}
/**
 * 刷新订单基本信息
 */
function refreshDetailPage(){
	findDetailAjax.send();
	MsgBox.getCurrentOpenDialogWindow().refreshT();
}